﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

public partial class PMSWeb_DesktopTask : BasePage
{
    private string cmdText = @"select top 7 a.TaskCode,a.TaskItemID,a.TaskID,a.SNYear,a.SNGroup,a.SNTask,a.SNProject,a.SNDispatch,a.TaskState,D.CodeName as GroupName,C.Guest,C.Phone,C.Location,C.RoomNo,C.HouseNo,C.TroubleDescription,C.IsRequestGood,C.CreateDate from PMS_TaskItem a 
                    left join PMS_TaskLX C on c.TaskID = a.TaskID  left join T_CodeConfig D on D.CodeValue=a.SNGroup AND D.Category = '" + PMSCodeCategory.PMS_BMZB + "' where 1=1 and a.TaskState='" + PMSTaskState.Running + "' ORDER BY C.CreateDate DESC";
     
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //string cmdText = string.Format("SELECT top 7 * FROM {0} ORDER BY CreateDate DESC", "PMS_TaskLX");
            DataSet ds = PMSAccess.GetDataSet(this.Connection, cmdText);
            StringBuilder sbTemp = new StringBuilder();
            int index = 1;
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                sbTemp.AppendLine("<tr>");
                sbTemp.AppendLine("<td><img src=\"../App_Themes/DefaultSkin/Image/da" + index.ToString() + ".jpg\" alt=\"" + index.ToString() + "\" ></td>");
                //sbTemp.AppendLine("<td>" + row["Guest"].ToString() + "</td>");
                //sbTemp.AppendLine("<td><a target='_parent' href='../PMSWeb/TaskAcceptDispatch.aspx?TaskID=" + row["TaskID"].ToString() + "'>" + row["Location"].ToString() + "</a></td>");
                sbTemp.AppendLine("<td><a target='_parent' href='../PMSWeb/TaskDispatch.aspx?TaskItemID=" + row["TaskItemID"].ToString() + "'>" + row["Guest"].ToString() + "(" + row["GroupName"].ToString() + ")" + "</a></td>");
                sbTemp.AppendLine("<td>" + PMSTaskState.GetName(row["TaskState"].ToString()) + "</td>");
                sbTemp.AppendLine("<td>" + Convert.ToDateTime(row["CreateDate"].ToString()).ToString("MM-dd HH:ss") + "</td>");
                sbTemp.AppendLine("<tr>");
                index++;
            }
            for (int i = index; i < 8; i++)
            {
                sbTemp.AppendLine("<tr>");
                sbTemp.AppendLine("<td>&nbsp;</td>");
                sbTemp.AppendLine("<td>&nbsp;</td>");
                //sbTemp.AppendLine("<td>&nbsp;</td>");
                sbTemp.AppendLine("<td>&nbsp;</td>");
                sbTemp.AppendLine("<td>&nbsp;</td>");
                sbTemp.AppendLine("<tr>");
            }

            literal.Text = sbTemp.ToString();
        }
    }
}
  